#ifndef VIDEOREAD_H
#define VIDEOREAD_H

#include <QObject>
#include <QImage>
#include <QTimer>
#include <QMessageBox>
#include <QDebug>
#include "command.h"
#include "myfacedetect.h"
#include <QPainter>

class videoRead;
class videoWorker;

class videoRead : public QObject
{
    Q_OBJECT
public:
    explicit videoRead(QObject *parent = 0);
    ~videoRead();

signals:
    void SIG_sendVideoFrame(QImage img);

public slots:
    void slot_openVideo();
    void slot_closeVideo();
    void slot_getVideoFrame();
    void slot_setMoji(int moji);//设置滤镜
private:
    QTimer* m_timer;

    //OpenCV获取图片对象
    cv::VideoCapture cap;
    QSharedPointer<videoWorker> m_pVideoWorker;

    //矩形框数组 成员对象 存上一次的矩形
    std::vector<Rect> m_vecLastFace;

    enum moji_type {moji_tuer = 1,moji_hat = 2};
    int m_moji;//用于存储当前滤镜效果 1兔耳，2帽子

    QImage m_tuer;
    QImage m_hat;
};

class videoWorker:public ThreadWorker
{
    Q_OBJECT
public slots:
    void slot_setInfo(videoRead* p)
    {
        m_pVideoRead = p;
    }

    //定时器到时，就执行
    void slot_doWork()
    {
        m_pVideoRead->slot_getVideoFrame();
    }

private:
    videoRead* m_pVideoRead;
};

#endif // VIDEOREAD_H
